function createObject(open) {
	var r = new Job(BasePath.get() + "/livcos.org/web/editor/CreateObject.job")
	r.addFormData(document.forms[0]);
	r.onCompleted = function() {
		var msg = document.getElementById("message");
		msg.innerHTML = "test";
		var root = this.dom.documentElement;
		var action = Dom(root).getChild("create");
		if (action) {
			// successful
			if (open) {
				window.location.replace(window.location.href);
			}
			else {
				var objId = action.getAttribute("objId");
				msg.innerHTML = "Object <a href=\"" + BasePath.get() + objId + "\">"
				    + objId + "</a> successfully created!<br/>Click <a href=\""
				    + BasePath.get() + "/livcos.org/web/data/view.html?ref=" + objId
				    + "\">here</a> to edit.";
			}
		}
		else {
			// failure
			var objId = document.getElementById("objId").value;
			var ex = Dom(root).getChild("exception");
			msg.innerHTML = 'Failed to create object <a href="' + BasePath.get()
			    + objId + '">' + objId + '</a>!<br/><br/>';
			msg.innerHTML += 'Exception: ' + Dom(ex).getTextContent() + '<br/><br/>';
			msg.innerHTML += 'see the complete <a href="javascript:Dom(\'response\').toggle();">Response</a>';
			var xslt = new Resource(BasePath.get() + "/livcos.org/web/style/meta_content.xsl");
			xslt._data = this;
			xslt.onCompleted = function() {
				this._data.transform(this, document.getElementById("response"));
			};
			xslt.load();
		}
		msg.style.display = "block";
	};
	r.start();
}

function setTmpl(objId) {
	Dom("tmplId").element.value = objId;
}

new EventListener(window, "load", function(evn) {
	Dom("objId").setRefAutoComplete("/");
	Dom("tmplId").setRefAutoComplete("/");
});
